/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * Copyright (c) 2013-2014 sagyf Yang. The Four Group.
 */

define([ 'adminapp'], function ($app) {

    // nav menu
    $app.navactive('floor');

    var action_tpl = Handlebars.compile($(g.actiontpl).html());
    var pircute_tpl = Handlebars.compile($(g.pircutetpl).html());

    $app.listtable({
        'sAjaxSource' : g.ctx + "admin/floor/list",
        'aoColumns'   : [
            $app.checkall,
            $app.autono,
            {'mDataProp': 'id' },
            {'mDataProp': 'name' },
            {'mDataProp': 'description' },
            {'mDataProp': 'picture' },
            {'mDataProp': 'area' },
            {'mDataProp': 'mall' }
        ],
        'aoColumnDefs': [
            { 'bSearchable': false, 'bVisible': false, 'aTargets': [ 2 ] },
            { 'bSearchable': false, 'bVisible': false, 'aTargets': [ 6 ] },
            { 'bSearchable': false, 'bVisible': false, 'aTargets': [ 7 ] },
            {
                'aTargets': [5],
                'mData'   : null,
                'mRender' : function (data, type, full) {
                    if(full['picture']){
                        full['portfolio'] = full['picture'].replace('.', '.thumbnail.');
                    }
                    return pircute_tpl(full);
                }
            },
            {
                'aTargets': [8],
                'mData'   : null,
                'mRender' : function (data, type, full) {
                    return action_tpl(full);
                }
            }
        ]
    }, 'floor-list');

});